﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ReactReduxTool.UI.Dialog;

namespace ReactReduxTool.Utils
{

    public class DialogUtil
    {

        private DialogUtil()
        {
        }

        public delegate void OnAppExitListener();

        /// <summary>
        /// 提示是否退出应用的提示
        /// </summary>
        /// <param name="listener"></param>
        public static void ShowExitAlertDialog(OnAppExitListener listener)
        {
            DialogResult result = MessageBox.Show("确定退出应用吗？", "温馨提示", MessageBoxButtons.YesNo);
            if (result == DialogResult.Yes)
            {
                listener();
            }
        }

        public delegate void OnChooseDirectoryListener(string folderName);

        /// <summary>
        /// 选择目标文件夹
        /// </summary>
        /// <param name="listener"></param>
        public static void ShowChooseTargetDirectory(OnChooseDirectoryListener listener)
        {
            FolderBrowserDialog dialog = new FolderBrowserDialog();
            dialog.Description = "请选择文件夹";
            if (dialog.ShowDialog() == DialogResult.OK || dialog.ShowDialog() == DialogResult.Yes)
            {
                listener(dialog.SelectedPath);
            }
        }

        /// <summary>
        /// 显示输入窗口
        /// </summary>
        /// <param name="message"></param>
        /// <param name="listener"></param>
        /// <returns></returns>
        public static DialogResult ShowInputDialog(string message, DialogInput.OnPublishContentListener listener)
        {
            DialogInput dialog = new DialogInput();
            dialog.InitDialog(message);
            dialog.SetOnPublishCntentListener(listener);
            return dialog.ShowDialog();
        }

    }

}
